package cn.csg.iotplatform.module.system.kafka;

import cn.csg.iotplatform.module.system.dal.dataobject.logger.GatewayLog;
import cn.csg.iotplatform.module.system.dal.dataobject.logger.GatewayLogDO;
import cn.csg.iotplatform.module.system.dal.mysql.logger.GatewayLogMapper;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author lujifa@jxtech
 * @version 1.0.0
 * @Description 物模型服务相关队列消费者
 * @createTime 2021年08月10日 08:59:00
 */
@Component
public class LoggerQueueListener {

    private static Logger log = LoggerFactory.getLogger(LoggerQueueListener.class);
    @Resource
    private GatewayLogMapper gatewayLogMapper;


//    @KafkaListener( topicPattern = "GATEWAY_LOGGER_QUEUE", concurrency = "10", groupId = "LOCAL_GATEWAY_LOGGER_GROUP4" )
    public void msgHandler(String msg) {
       try {
           /*log.info("GATEWAY_LOGGER_QUEUE监听获取消息：{}",msg);
           GatewayLog gatewayLog=JSONObject.parseObject(msg, GatewayLog.class);
           GatewayLogDO gatewayLogDO = new GatewayLogDO();
           BeanUtils.copyProperties(gatewayLog,gatewayLogDO);
           gatewayLogMapper.insert(gatewayLogDO);*/

       }catch (Exception e){
           log.error("处理日志失败",e);
       }
    }

}
